package com.ilink.teacherservice.controller.bailian;


import com.ilink.ilinkcommon.domain.R;
import com.ilink.ilinkcommon.log.method.MethodLog;
import com.ilink.ilinkcommon.utils.UserContext;
import com.ilink.teacherservice.service.bailian.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/teacher/bailain_index")
public class IndexController {

    @Autowired
    IndexService indexService;

    /**
     * @Author BlackCurry
     * @Description 小链索引RAG召回
     * @Date 14:25 2024/10/5
     * @Param [query 表示用户输入的自然语言, path 表示]
     * @return com.ilink.ilinkcommon.domain.R
     **/
    @MethodLog
    @PostMapping("/retrieve")
    public R retrieveIndex(String query, String path) {
        try {
            String userId = UserContext.getUserId();
            return indexService.retrieveIndex(userId, query, path);
        } catch (Exception e) {
            return R.error("检索失败");
        }
    }
}
